<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    
	
	<title>_订单详细信息</title>
	
    <script type="text/javascript">
		function  ajaxWhInfo(ordeno,optype){
			$.ajax({
				type : 'post',
				url : '${ctx}/orderMsg/ajaxWhInfo',
				data : 'ordeno=' + ordeno + '&optype=' + optype,
				dataType : 'json',
				success : function(data) {
				   alert(data.content);
				},
				error : function() {
					alert("获取信息错误！");
				}
			});
	  }
	  function reviseWorkStatus(orderNo){
		  $.ajax({
				type : 'post',
				url : '${ctx}/orderMsg/reviseWorkStatus',
				data : 'orderNo=' + orderNo,
				dataType : 'json',
				success : function(data) {
					alert(data.content);
				   if(data.status == "1"){
					   window.location.href = 'http://localhost:8080/wms/orderMsg/v2_orderMsgDetail/'+orderNo;
				   }
				},
				error : function() {
					alert("获取信息错误！");
				}
			});
	  }
	  
	  function showDetail(e) {
			var id = $(e).attr("id");
			var info = id.split("_");
			var customerCode = info[0];
			var warehouseCode = info[1];
			var sku = info[2];

			$("#customerName").html(customerCode);
			$("#warehouseName").html(warehouseCode);
			$("#sku").html(sku);

			$.ajax({
				type : 'post',
				url : '${ctx}/cusStock/stockDetail',
				data : {
					customerCode : customerCode,
					warehouseCode : warehouseCode,
					sku : sku
				},
				dataType : 'json',
				success : function(data) {
					var stockList = data.stockList;

					//库位信息
					$("#detail_content").html("");
					var str = '';
					$.each(stockList, function(i) {
						var stock = stockList[i];
						str += "<tr>";
						str += "<td>" + stock.stockCode + "</td>";
						str += "<td>" + stock.boxCode + "</td>";
						str += "<td>" + stock.salesNum + "</td>";
						str += "<td>" + stock.unusedNum + "</td>";
						str += "<td>" + stock.orderNum + "</td>";
						str += "<td>" + stock.lockedNum + "</td>";
						str += "<td>" + stock.transportNum + "</td>";
						str += "<td>" + stock.airNum + "</td>";
						str += "<td>" + stock.totalNum + "</td>";

						var boxType = stock.boxType;

						if (boxType == 'prepkg') {
							str += "<td><font color=blue>预包装</font></td>";
						} else {
							str += "<td>普通</td>";
						}

						str += "</tr>";
					});
					$("#detail_content").html(str);

				},
				error : function() {
					alert("网络繁忙，请稍后重试...");
				}
			});
		}
	</script>
	
</head>



<body>
<section class="content">
 <div class="form-group row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
				<div class="box-header">
					<h3 class="box-title">订单信息</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse" type="button">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
	<div class="box-body">
	<!-- 订单信息 -->	
	<table id="contentTable" class="table table-striped table-bordered table-condensed" style="table-layout: fixed;">
		<thead><tr>
		    <th>能容订单号</th>
		    <th>商家订单号</th>
		    <th>来源订单号</th>
		    <th>作业仓库</th>
		    <th>作业批次号</th>
			<th>作业任务号</th>
			<th>快递单号（公司）</th>
			<th>发货重量(g)</th>
		 </tr></thead>
		 <tr>
		   <td>${order.order.ordeno}</td>
		   <td>${order.order.customerOrdeno}</td>
		   <td style="width:60px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">${order.order.fromno}</td>
		   <%-- <td>${order.warehouse.groupName}</td> --%>
		   <td>${order.warehouseCode}</td>
		   <td>${order.batchCode}</td>
		   <td><a href='${ctx}/orderMsg/v2_queryOrderMsg?_taskCode=${order.taskCode}'>${order.taskCode}</a></td>
		   <td>${order.ebillNo}${order.expressNo}（${order.expressCompany}）</td>
		   <td>${order.weight}</td>
		 </tr>
		 <thead><tr>
		   <th>收件人</th>
			<th>联系电话</th>
			<th>联系手机</th>
			<th>省/市/区</th>
			<th colspan="2">详细地址</th>
			<th>订单类型</th>
			<th>订单状态</th>
		 </tr></thead>
		  <tr>
		   <td>${order.order.recena}</td>
		   <td>${order.order.mobile}</td>
		   <td>${order.order.teleph}</td>
		   <td>${order.order.provna}/${order.order.cityna}/${order.order.distna}</td>
		   <td colspan="2">${order.order.addres}</td>
		   <td >
		       <c:if test="${order.cancelStatus eq 'ok'}">正常单</c:if>
		       <c:if test="${order.cancelStatus eq 'cancel'}"><font color=red>取消单</font></c:if>
		       <c:if test="${order.cancelStatus eq 'refuse'}"><font color=red>拒收单</font></c:if>
		       <c:if test="${order.cancelStatus eq 'change'}"><font color=red>换货单</font></c:if>
		       <c:if test="${order.cancelStatus eq 'outScope'}"><font color=red>超区件</font></c:if>
		       <c:if test="${order.cancelStatus eq 'lose'}"><font color=red>丢件单</font></c:if>
		   </td>
		   <td style="color: blue; font-weight: bold;">
                  <!-- 订单状态 (1.创建批次 2.创建任务 3.已拣货  4.已灯光拣选  9.待包装   5.已包装  6.已发货  7.已签收  8.异常 ) -->
				     <c:if test="${order.status eq '1'}">创建批次</c:if>
				     <c:if test="${order.status eq '2'}">创建任务</c:if>
				     <c:if test="${order.status eq '3'}">已拣货</c:if>
				     <c:if test="${order.status eq '4'}">已灯光拣选</c:if>
				     <c:if test="${order.status eq '9'}">待包装</c:if>
				     <c:if test="${order.status eq '5'}">已包装</c:if>
				     <c:if test="${order.status eq '6'}">已发货</c:if>
				     <c:if test="${order.status eq '7'}">已签收</c:if>
				     <c:if test="${order.status eq '8'}">异常</c:if>
		   </td>
		 </tr>
		 <thead><tr>
		   <th>发票号</th>
		   <th>发票抬头</th>
		   <th>指定快递</th>
		   <th colspan="2">卖家留言</th>
			<th colspan="3">商家留言</th>
		 </tr></thead>
		 <tr>
		 	<td>${order.invoiceNo}</td>
		 	<td>${order.order.invoiceTitle}</td>
		 	<td>${order.order.oldCacode}</td>
		 	<td colspan="2">${order.order.sememo}</td>
		 	<td colspan="3">${order.order.shmemo}</td>
		 </tr>
	</table>
	</div>
	</div>
	</div>
	</div>
	
	<div class="form-group row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
				<div class="box-header">
					<h3 class="box-title">商品信息</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse" type="button">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
	<div class="box-body">
	<!-- 商品信息 -->	
	<table id="contentTable" class="table  table-bordered table-condensed">
		<thead><tr>
		    <th>商品名称</th>
		    <th>SKU</th>
		    <th>数量</th>
		    <th>单价（元）</th>
			<th>折扣（元）</th>
			<th>应付金额（元）</th>
			<th>商品描述</th>
		 </tr></thead>
		 
		 <c:forEach  items="${itemList}" var="orderItem">
			 <tr>
			   <td>${orderItem.nam}</td>
			   <td><a href="#detail" data-toggle="modal" id="${order.order.customerCode}_${order.order.warehouseCode}_${orderItem.sku}" onclick="showDetail(this);">${orderItem.sku}</a></td>
			   <td>${orderItem.qty}</td>
			   <td>${orderItem.pri}</td>
			   <td>${orderItem.dis}</td>
			   <td>${orderItem.pay}</td>
			   <td>${orderItem.des}</td>
			 </tr>
		 </c:forEach>
	</table>
	</div>
	</div>
	</div>
	</div>
	
<div class="form-group row">
		<div class="col-md-12">
			<div class="box box-solid box-primary">
				<div class="box-header">
					<h3 class="box-title">作业日志
					<%-- <button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="reviseWorkStatus('${order.order.ordeno}');" >修正作业状态</button> --%>
					</h3>
					<div class="box-tools pull-right">
						<button class="btn btn-primary btn-sm" data-widget="collapse" type="button">
							<i class="fa fa-minus"></i>
						</button>
					</div>
				</div>
	<div class="box-body">	
	<!-- 作业日志 -->	
	<table id="contentTable" class="table  table-bordered table-condensed">
		<thead><tr>
		    <th style="width: 100px;">处理人</th>
		    <th style="width: 170px;">处理时间</th>
			<th style="width: 100px;">处理环节</th>
			<th >描述</th>
			 <shiro:hasRole name="admin">
			<th >操作</th>
			</shiro:hasRole>
		</tr></thead>
		<c:forEach  items="${logList}" var="log">
			 <tr>
		       <td>${log.operater.realname}</td>
		       <td>${fn:substring(log.operateTime,0,19)}</td>
		       <td>
		        <!-- 操作类型 （1.创建批次 2.创建任务 3.拣货完成 4.包装完成 5.发货完成 6.签收完成 7.异常登记 8.完成灯光拣选任务 9.打印单据 10.取消单 11.异常单重发 12.取消单拦截标识 13.登记异常单 14.退回单收货 15.退回单质检 16.退回单入库） -->
		         <c:if test="${log.operateType eq '1'}">创建批次</c:if>
			     <c:if test="${log.operateType eq '2'}">创建任务</c:if>
			     <c:if test="${log.operateType eq '3'}">拣货完成 </c:if>
			     <c:if test="${log.operateType eq '4'}">包装完成</c:if>
			     <c:if test="${log.operateType eq '5'}">发货完成</c:if>
			     <c:if test="${log.operateType eq '6'}">签收</c:if>
			     <c:if test="${log.operateType eq '7'}">异常登记</c:if>
			     <c:if test="${log.operateType eq '8'}">完成灯光拣选</c:if>
			     <c:if test="${log.operateType eq '9'}">打印单据</c:if>
			     <c:if test="${log.operateType eq '10'}">取消单</c:if>
			     <c:if test="${log.operateType eq '11'}">异常单重发</c:if>
			     <c:if test="${log.operateType eq '12'}">拦截标识</c:if>
			     <c:if test="${log.operateType eq '13'}">打印单据</c:if>
			     <c:if test="${log.operateType eq '14'}">退回件收货</c:if>
			     <c:if test="${log.operateType eq '15'}">退回件质检</c:if>
			     <c:if test="${log.operateType eq '16'}">退回件入仓</c:if>
			     <c:if test="${log.operateType eq '17'}">登记异常单</c:if>
			     <c:if test="${log.operateType eq '18'}">打印发票</c:if>
		       </td>
		       <td>${log.aboutInfo}</td>
		       <shiro:hasRole name="admin">
		      <td>
		       		<c:if test="${log.operateType eq '4'}">
		       			<button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="ajaxWhInfo('${log.orderno}','${log.operateType}');" >回传</button>
		       		</c:if>
		       		<c:if test="${log.operateType eq '3'}">
		       			<button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="ajaxWhInfo('${log.orderno}','${log.operateType}');" >回传</button>
		       		</c:if>
		       		<c:if test="${log.operateType eq '5'}">
		       			<button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="ajaxWhInfo('${log.orderno}','${log.operateType}');" >回传</button>
		       		</c:if>
		       		<c:if test="${log.operateType eq '9'}">
		       			<button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="ajaxWhInfo('${log.orderno}','${log.operateType}');" >回传</button>
		       		</c:if>
		       		<c:if test="${log.operateType eq '1'}">
		       			<button type="button" class="btn btn-info" style="margin-left: 10px;" onclick="ajaxWhInfo('${log.orderno}','${log.operateType}');" >回传</button>
		       		</c:if>
		       </td>
		       </shiro:hasRole>
			 </tr>
		</c:forEach>
	</table>
	</div>
	</div>
	</div>
	</div>

</section>
<!-- 库存明细 -------------------------------------------------------------------------------------------------->
	<div  class="modal fade"  id="detail" >
	<form id="inputForm"  method="post" class="form-horizontal">
	<div class="modal-dialog">
			<div class="modal-content">
		<!-- 头 -->
		<div class="modal-header" ></div>
		<!-- 体 -->
		<div class="modal-body" style="height: 400px; overflow: scroll;">
		
		   <table class="table table-striped table-bordered table-condensed" >
        	  <thead>
        	    <th style="color: white;" bgcolor="#8EB4CB">商家</th>
			    <th style="color: white;" bgcolor="#8EB4CB">商家仓库</th>
			    <th style="color: white;" bgcolor="#8EB4CB">sku编码</th>
			  </thead>
	          <tr>
	             <td id="customerName"></td>
	             <td id="warehouseName"></td>
	             <td id="sku"></td>
	          </tr>
	        </table>  
		
			<table id="contentTable" class="table table-striped table-bordered table-condensed">
			<thead>
			<th style="vertical-align: middle; color: white;" bgcolor="#8EB4CB" colspan="10">库存信息</th>
			<tr>
			    <th style="width: 100px;">库位编码</th>
			    <th style="width: 100px;">箱子编码</th>
			    <th style="width: 100px;">可销售库存</th>
			    <th style="width: 100px;">不可销售库存</th>
			    <th style="width: 100px;">订单占用库存</th>
			    <th style="width: 100px;">锁定库存</th>
			    <th style="width: 100px;">调拨占用库存</th>
			    <th style="width: 100px;">调拨中库存</th>
			     <th>总量</th>
			    <th style="width: 100px;">存放类型</th>
			   
			</tr></thead>
			<tbody id="detail_content"></tbody>
			</table>		       
		      
		</div>
		<!-- 尾 -->
		<div class="modal-footer">
			<a class="btn btn-primary" data-dismiss="modal" aria-hidden="true">返回</a>
		</div>
		</div>
		</div>
        </form> 
     </div>
     <!------------------------------------------------------------------------------------------------------------->
</body>
</html>
